<?php


namespace app\store\model;

use think\Model;
use think\model\concern\SoftDelete;

class Coupon extends Model
{
    use SoftDelete;


    protected $autoWriteTimestamp = 'int';

    protected $defaultSoftDelete = 0;

    protected $schema = [
        'id' => 'int',
        'store_id' => 'int',
        'coupon_type' => 'int',
        'coupon_name' => 'string',
        'icon' => 'string',
        'expire_type' => 'int',
        'start_time' => 'int',
        'end_time' => 'int',
        'expire_day' => 'int',
        'with_amount' => 'float',
        'used_amount' => 'float',
        'quota' => 'int',
        'is_integral_redeem' => 'int',
        'redeem_integral' => 'int',
        'grant_count' => 'int',
        'used_count' => 'int',
        'desc' => 'string',
        'status' => 'int',
        'create_time' => 'int',
        'update_time' => 'int',
        'delete_time' => 'int',
    ];

    public function setStartTimeAttr($value)
    {
        return strtotime($value);
    }

    public function setEndTimeAttr($value)
    {
        return strtotime($value);
    }
    
    public function goods()
    {
        return $this->belongsToMany(Goods::class,CouponGoods::class);
    }

}